using UnityEngine;
using System.Collections;

public class StoneEffect : MonoBehaviour {

    const float c_SoundRadius = 30;
    Vector3 m_Destination;
    const float speed = 20;

    bool started = false;
    StoneBehaviour m_Stone;
    public void StartEffect(Vector3 startingPosition, Vector3 destination,StoneBehaviour stone)
    {
        started = true;
        m_Destination = destination;
        this.transform.position = startingPosition;
        m_Stone = stone;
    }
    public void Update()
    {
        this.transform.position += (m_Destination - this.transform.position).normalized * speed * Time.deltaTime;
        if (Vector3.Distance(m_Destination, this.transform.position) <= 1)
        {
            VisionManager.GetInstance().GenerateSound(m_Destination + Vector3.up, c_SoundRadius);
            EndEffect();
        }
    }
    void EndEffect()
    {
        m_Stone.beingUsed = false;
        GameObject.Destroy(this.gameObject);
    }
}
